package com.dyava.commons.validate;

import java.math.BigDecimal;

public class ValidateBigDecimal extends Validate<BigDecimal,ValidateBigDecimal> {
	
	public ValidateBigDecimal(BigDecimal value,String name) {
		this.value = value;
		this.name = name;
	}

	public ValidateBigDecimal gt(BigDecimal value){
		if (checkNull()) return this;
		if(this.value.compareTo(value)>0){
			return this;
		}
		throw new ValidateFastException(name+"必须大于"+value);
	}

	public ValidateBigDecimal lt(BigDecimal value){
		if (checkNull()) return this;
		if(this.value.compareTo(value)<0){
			return this;
		}
		throw new ValidateFastException(name+"必须小于"+value);
	}

	public ValidateBigDecimal ge(BigDecimal value){
		if (checkNull()) return this;
		if(this.value.compareTo(value)>=0){
			return this;
		}
		throw new ValidateFastException(name+"必须大于等于"+value);
	}

	public ValidateBigDecimal le(BigDecimal value){
		if (checkNull()) return this;
		if(this.value.compareTo(value)<=0){
			return this;
		}
		throw new ValidateFastException(name+"必须小于等于"+value);
	}


	public ValidateBigDecimal gt(double value){
		if (checkNull()) return this;
		if(this.value.compareTo(BigDecimal.valueOf(value))>0){
			return this;
		}
		throw new ValidateFastException(name+"必须大于"+value);
	}

	public ValidateBigDecimal lt(double value){
		if (checkNull()) return this;
		if(this.value.compareTo(BigDecimal.valueOf(value))<0){
			return this;
		}
		throw new ValidateFastException(name+"必须小于"+value);
	}

	public ValidateBigDecimal ge(double value){
		if (checkNull()) return this;
		if(this.value.compareTo(BigDecimal.valueOf(value))>=0){
			return this;
		}
		throw new ValidateFastException(name+"必须大于等于"+value);
	}

	public ValidateBigDecimal le(double value){
		if (checkNull()) return this;
		if(this.value.compareTo(BigDecimal.valueOf(value))<=0){
			return this;
		}
		throw new ValidateFastException(name+"必须小于等于"+value);
	}





}
